﻿////#define _CRT_SECURE_NO_WARNINGS  1
//////一定要动手，例子不管多么简单，建议至少自己手敲一遍看看是否理解了里头的细枝末节。
//////一定要学会思考，思考为什么要这样，而不是那样。还要举一反三地思考
//#include<string>
//#include<iostream>
//using namespace std;
////class goodgay {
////
////};
////class building {
////	friend void goodgay(building* build);
////private:
////	string bedroom;
////public:
////	string sitingroom;
////public:
////	building()
////	{
////		bedroom = "卧室";
////		sitingroom = "客厅";
////	}
////};
//////全局函数做友元
//////void goodgay(building * build)
//////{
//////	cout << "好朋友的全局函数正在访问：" << build->sitingroom << endl;
//////	cout << "好朋友的全局函数正在访问：" << build->bedroom << endl;
//////
//////}
////int main()
////{
////	building p1;
////	//goodgay(&p1);
////	system("pause");
////	return 0;
////}
////class Building;
////class Goodboy {
////public:
////	void visit();  //通过building访问Building中的成员属性
////	Building* building;
////	Goodboy();
////};
////class Building {
////	friend class Goodboy;   //Goodboy类是本类的好朋友，可以访问本类中私有的成员
////private: 
////	string bedroom;
////public:
////	string livingroom;
////public:
////	Building();
////};
////Building::Building()
////{
////	bedroom = "卧室";
////	livingroom = "大厅";
////}
////Goodboy::Goodboy()
////{
////	building = new Building;
////}
//// void Goodboy::visit()
////{
////	 cout << "好朋友正在访问：" << building->livingroom << endl;
////	 cout << "好朋友正在访问：" << building->bedroom<< endl;
////
////}
//// void test1()
//// {
////	 Goodboy  p1;
////	 p1.visit();
//// }
//// int main()
//// {
////	 test1();
////	 return 0;
//// }
//class Building;
//class Goodboy {
//public:
//	Building* _building;
//	Goodboy();
//	void visit1();//可以访问Building中的私有成员
//	void visit2();//不可以访问Building中的私有成员
//};
//class Building {
//	friend void Goodboy::visit1();
//public:
//	string _bedroom;
//private:
//	string _livingroom;
//public:
//	Building();
//};
//Building::Building()
//{
//	_bedroom = "卧室";
//	_livingroom = "客厅";
//}
//Goodboy::Goodboy()
//{
//	_building = new Building;
//}
//void Goodboy::visit1()
//{
//
//	cout << "Goodboy  1正在参观：" << _building->_livingroom << endl;
//	cout << "Goodboy  2正在参观：" << _building->_bedroom << endl;
//
//}
//void Goodboy::visit2()
//{
//	//cout << "Goodboy  2正在参观：" << _building->_livingroom << endl;
//	cout << "Goodboy  2正在参观：" << _building->_bedroom << endl;
//}
//void test()
//{
//	Goodboy p1;
//	p1.visit1();
//	p1.visit2();
//}
//int main()
//{
//	test();
//	return 0;
//}